//
//  Open_ShoppingViewController.m
//  OpenYooxi_IOS
//
//  Created by YeahYes on 15/3/16.
//  Copyright (c) 2015年 com.ivyvi.ee. All rights reserved.
//

#import "Open_ShoppingViewController.h"
#import "GouWuChe_TableViewCell.h"

static NSString *identify = @"Cell";


@interface Open_ShoppingViewController ()

@end

@implementation Open_ShoppingViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.title = @"购物车";
    
    
    //1.右边的item自定义
    UIView *quanview = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 50, 14)];
    UIButton *imgbutton = [UIButton buttonWithType:UIButtonTypeCustom];
    imgbutton.frame = CGRectMake(0, 0, 50, 14);
    [imgbutton setImage:[UIImage imageNamed:@"6__03"]
                 forState:UIControlStateNormal];
    [imgbutton addTarget:self action:@selector(rightAction:)
          forControlEvents:UIControlEventTouchUpInside];
    
    [quanview addSubview:imgbutton];
    UIBarButtonItem *rightItem = [[UIBarButtonItem alloc] initWithCustomView:quanview];
    self.navigationItem.rightBarButtonItem = rightItem;
    
    
    _quanxuanlabel.font = [UIFont boldSystemFontOfSize:13];
    _hejilabel.font = [UIFont boldSystemFontOfSize:15];
    _jiesuanbutton.titleLabel.font = [UIFont boldSystemFontOfSize:12];
    _jiesuanbutton.contentHorizontalAlignment = UIControlContentHorizontalAlignmentCenter;
    
    
    
    _gouwuchetableview.dataSource = self;
    _gouwuchetableview.delegate = self;
    //    _ShouChangTableview.pagingEnabled = YES;
    _gouwuchetableview.separatorStyle = UITableViewCellSeparatorStyleNone;
    //取消tableview右侧的滑动条
    _gouwuchetableview.showsVerticalScrollIndicator = NO;
    _gouwuchetableview.backgroundColor = [UIColor whiteColor];
    
    
    //注册uitableviewcell
    UINib *nib = [UINib nibWithNibName:@"GouWuChe_TableViewCell" bundle:[NSBundle mainBundle]];
    [_gouwuchetableview registerNib:nib forCellReuseIdentifier:identify];
    
}


#pragma mark - UITableView delegate 设置单元格高度
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
    
    return 90;
}


- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return 6;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    
    GouWuChe_TableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:identify forIndexPath:indexPath];
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
    return cell;
}










#pragma mark - 道航栏右侧按钮的点击事件
- (void)rightAction:(UIButton *)button {
    MyLog(@"点击了");
}


#pragma mark - 结算了
- (IBAction)jiesuanclick:(UIButton *)sender {
    MyLog(@"结算了");
}


#pragma mark - 全选了
- (IBAction)quanxuanclick:(UIButton *)sender {
    if(sender.selected){
        [_quanxuanbutton setImage:[UIImage imageNamed:@"6_10"] forState:UIControlStateNormal];
    }else{
        [_quanxuanbutton setImage:[UIImage imageNamed:@"6_07"] forState:UIControlStateNormal];
    }
    //切换设置选择状态
    sender.selected = !sender.selected;
    
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
